package cnsatmsmart.automation.mmi.view.dialogs;

import cnsatmsmart.automation.mmi.helper.utilities.GlobalEnvVars;
import java.awt.Image;
import org.jdesktop.application.Action;

/**
 *
 * @author SIK - PTIK, BPPT
 */
public class flightSetting extends javax.swing.JDialog {

    /** Creates new form flightSetting
     * @param parent jendela yang memanggilnya
     * @param modal ada atau tidaknya dialog
     */
    public flightSetting(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        Image frameIcon = GlobalEnvVars.kit.getImage(getClass().getResource("/cnsatmsmart/resources/"+GlobalEnvVars.icon));
        setIconImage(frameIcon);
        setTitle("Flight Options");
        setResizable(false);

        loadProperty();
    }

    private void loadProperty()
    {
        cbCode.setSelected(GlobalEnvVars.showCode);
        cbAltitude.setSelected(GlobalEnvVars.showAltitude);
        cbLatitude.setSelected(GlobalEnvVars.showLat);
        cbLongitude.setSelected(GlobalEnvVars.showLon);
        cbGroundSpeed.setSelected(GlobalEnvVars.showSpeed);
        cbTrackAngle.setSelected(GlobalEnvVars.showTrackangle);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnSave = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        cbAltitude = new javax.swing.JCheckBox();
        cbCode = new javax.swing.JCheckBox();
        cbLatitude = new javax.swing.JCheckBox();
        cbLongitude = new javax.swing.JCheckBox();
        cbGroundSpeed = new javax.swing.JCheckBox();
        cbTrackAngle = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(cnsatmsmart.CNSATMSMARTApp.class).getContext().getActionMap(flightSetting.class, this);
        btnSave.setAction(actionMap.get("clickSave")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(cnsatmsmart.CNSATMSMARTApp.class).getContext().getResourceMap(flightSetting.class);
        btnSave.setText(resourceMap.getString("btnSave.text")); // NOI18N
        btnSave.setName("btnSave"); // NOI18N

        btnCancel.setAction(actionMap.get("clickCancel")); // NOI18N
        btnCancel.setText(resourceMap.getString("btnCancel.text")); // NOI18N
        btnCancel.setName("btnCancel"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        cbAltitude.setText(resourceMap.getString("cbAltitude.text")); // NOI18N
        cbAltitude.setName("cbAltitude"); // NOI18N

        cbCode.setText(resourceMap.getString("cbCode.text")); // NOI18N
        cbCode.setName("cbCode"); // NOI18N

        cbLatitude.setText(resourceMap.getString("cbLatitude.text")); // NOI18N
        cbLatitude.setName("cbLatitude"); // NOI18N

        cbLongitude.setText(resourceMap.getString("cbLongitude.text")); // NOI18N
        cbLongitude.setName("cbLongitude"); // NOI18N

        cbGroundSpeed.setText(resourceMap.getString("cbGroundSpeed.text")); // NOI18N
        cbGroundSpeed.setName("cbGroundSpeed"); // NOI18N

        cbTrackAngle.setText(resourceMap.getString("cbTrackAngle.text")); // NOI18N
        cbTrackAngle.setName("cbTrackAngle"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(44, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbAltitude)
                    .addComponent(cbGroundSpeed)
                    .addComponent(cbLongitude)
                    .addComponent(cbCode)
                    .addComponent(cbLatitude)
                    .addComponent(cbTrackAngle))
                .addGap(26, 26, 26))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(cbCode)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbLatitude)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbLongitude)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbGroundSpeed)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbTrackAngle)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbAltitude)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnSave)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnCancel))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSave)
                    .addComponent(btnCancel))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * action untuk btnSave
     */
        @Action
        public void clickSave()
        {
            GlobalEnvVars.showCode = cbCode.isSelected();
            GlobalEnvVars.showAltitude = cbAltitude.isSelected();
            GlobalEnvVars.showLat = cbLatitude.isSelected();
            GlobalEnvVars.showLon = cbLongitude.isSelected();
            GlobalEnvVars.showSpeed = cbGroundSpeed.isSelected();
            GlobalEnvVars.showTrackangle = cbTrackAngle.isSelected();

            dispose();
        }
    
    /**
     * action untuk btnCancel
     */
        @Action
        public void clickCancel()
            {dispose();}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnSave;
    private javax.swing.JCheckBox cbAltitude;
    private javax.swing.JCheckBox cbCode;
    private javax.swing.JCheckBox cbGroundSpeed;
    private javax.swing.JCheckBox cbLatitude;
    private javax.swing.JCheckBox cbLongitude;
    private javax.swing.JCheckBox cbTrackAngle;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
